#include <linux/printk.h>

#include "chip_demo_gpio_led.h"
#include "board_led.h"

struct led_resource *led_board_A_res;


/*
	接收 led_drv.c 传递的初始化引脚参数
	负责初始化GPIO
*/
static int led_chip_init(int which)
{
	printk("%s: control led of %d\n", __FUNCTION__, which);

	if(!led_board_A_res){
		led_board_A_res = get_led_resource();
	}

	printk("init group %d, pin %d\n", GROUP(led_board_A_res->pin), pin(led_board_A_res->pin));
	
	return 0;
}


/*
	接收 led_drv.c 传递的控制引脚参数
	负责控制GPIO输出高低电平
*/
static int led_chip_ctl(int which, char status)
{
	printk("%s: control led of %d, status = %d\n", __FUNCTION__, which, status);

	printk("init group %d, pin %d\n", GROUP(led_board_A_res->pin), pin(led_board_A_res->pin));
	
	return 0;
}

	
/*
	led_chip_operations 结构体变量
	定义了GPIO个数
		  GPIO的初始化和控制函数指针
*/
static struct led_chip_operations led_chip_ops = {
	.led_init = led_chip_init,
	.led_ctl  = led_chip_ctl,
};


/* 
	返回 led_chip_operations 结构体
	供 led_drv.c 使用
*/
struct led_chip_operations *get_led_chip_ops(void)
{
	return &led_chip_ops;
}




